package cn.edu.ncut.cs.springboot.mybatisplusemployee.controller;

import cn.edu.ncut.cs.springboot.mybatisplusemployee.entity.Salary;
import cn.edu.ncut.cs.springboot.mybatisplusemployee.service.ISalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ncut
 * @since 2024-12-25
 */
@RestController
@RequestMapping("/salary")
public class SalaryController {
    @Autowired
    private ISalaryService salaryService;

    @PutMapping("/saveOrUpdate")
    public boolean saveOrUpdate(@RequestBody Salary salary) {
        return salaryService.saveOrUpdate(salary);
    }

    @GetMapping("/list")
    public List<Salary> list() {
        return salaryService.list();
    }
    @GetMapping("/{id}")
    public Salary getSalaryById(@PathVariable Long id) {
        return salaryService.getSalaryById(id);
    }

    @DeleteMapping("/delete/{id}")
    public boolean deleteSalary(@PathVariable Long id) {
        return salaryService.removeSalaryById(id);
    }
}
